package com.unittec.drainage.provider.auth.service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.unittec.drainage.provider.auth.entity.SysServiceRouter;
import com.unittec.drainage.provider.auth.mapper.SysServiceRouterMapper;
import com.unittec.drainage.provider.root.ServiceRoot;

/**
 * @author Jason
 * @description 路由Service
 * @date 2019/11/07
 */
@Service
public class SysServiceRouterServer extends ServiceRoot<SysServiceRouterMapper, SysServiceRouter> {

    /**
     * 查询所有应用服务ID集合
     *
     * @return
     */
    public List<String> findAllServiceIdList() {
        QueryWrapper<SysServiceRouter> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().select(SysServiceRouter::getServiceId);
        List<SysServiceRouter> list = super.list(queryWrapper);
        if (list == null || list.size() == 0) {
            return new ArrayList<>();
        }
        return list.parallelStream().map(SysServiceRouter::getServiceId).distinct().collect(Collectors.toList());
    }
}
